import { Base64 } from 'js-base64'

// 跳转商品列表页 type=true为替换
export function toProductList(_this, condition, type) {
  let data = {}
  if (condition) {
    data = condition
  }
  data = Base64.encodeURI(JSON.stringify(data))
  if (type) {
    _this.$router.replace({
      path: `/new-quence/${data}`
    })
  } else {
    _this.$router.push({
      path: `/new-quence/${data}`
    })
  }
}

// 跳转商品搜索页 type=true为替换
export function toSearchPage(_this, condition, type) {
  let data = {}
  if (condition) {
    data = condition
  }
  data = Base64.encodeURI(JSON.stringify(data))
  if (type) {
    _this.$router.replace({
      path: `/search/${data}`
    })
  } else {
    _this.$router.push({
      path: `/search/${data}`
    })
  }
}

// 跳转商品详情页
export function toProductDetail(_this, condition, end) {
  let data = {}
  let take = ''
  if (condition) {
    data = condition
  }
  if (end) {
    take = end
  }
  _this.$router.push({
    path: `/detail/${data}/${take}`
  })
}

// 跳转店铺列表
export function toShopList(_this, condition) {
  let data = {}
  if (condition) {
    data = condition
  }
  _this.$router.push({
    path: `/shop/${data}`
  })
}
